import { get, post } from '@/uitls/axios';

// 定义 Register 类型
type Register = {
  nickName: string;
  payload: string;
  verifyCode: string;
  loginPassword: string;
  paymentPassword: string;
  verifyId:string
};

// 定义 login 类型
type Login = {
    account: string;
    loginPassword: string;
    verifyCode: string;
    verifyId: string;
  };
  

// 注册
export const registerMemberFnApi = (register: Register) => {
  return new Promise((resolve, reject) => {
    post('/apis/member/registerMember', register)
      .then((response) => {
        resolve(response);
      })
      .catch((error) => {
        reject(error);
      });
  });
};


//登录
export const loginFnApi =(loginData:Login )=>{
    return new Promise((resolve, reject) => {
        post('/apis/member/memberLogin', loginData)
          .then((response) => {
            resolve(response);
          })
          .catch((error) => {
            reject(error);
          });
      });
}
//注册获取验证码
export const getRegisterMemberVerifyFnAPi =(data:any )=>{
  return new Promise((resolve, reject) => {
      get('/apis/member/getRegisterMemberVerify', data)
        .then((response) => {
          resolve(response);
        })
        .catch((error) => {
          reject(error);
        });
    });
}

export const getLoginVerifyFnAPi =(data:any )=>{
  return new Promise((resolve, reject) => {
      get('/apis/member/getLoginVerify', data)
        .then((response) => {
          resolve(response);
        })
        .catch((error) => {
          reject(error);
        });
    });
}



//重置获取验证码
export const getRestoreLoginPasswordVerifyFnApi =(data:any )=>{
  return new Promise((resolve, reject) => {
      get('/apis/member/getRestoreLoginPasswordVerify', data)
        .then((response) => {
          resolve(response);
        })
        .catch((error) => {
          reject(error);
        });
    });
}

//重置密码
export const restoreLoginPasswordFnAPi =(data:any )=>{
  return new Promise((resolve, reject) => {
      post('/apis/member/restoreLoginPassword', data)
        .then((response) => {
          resolve(response);
        })
        .catch((error) => {
          reject(error);
        });
    });
}

